import request from "@/utils/request.ts";
import type {SysResponse} from "@/api/commonType.ts";
import type {TagCard, TagForm} from "@/api/tag/type.ts";

export enum API {
  GET_TAG_LIST = "/api/tag/list",
  ADD = "/api/tag/add",
  DELETE = "/api/tag/delete",
  UPDATE = "/api/tag/update",
}

/**
 * 根据家庭Id 获取标签列表
 * @param familyId
 */
export function getTagListByFamilyId(familyId: number) {
  return request.get<string, SysResponse<TagCard[]>>(API.GET_TAG_LIST + `/${familyId}`)
}

/**
 * 添加标签
 * @param data
 * @param familyId
 */
export function addTag(data: TagForm, familyId: number) {
  return request.post<string, SysResponse<null>>(API.ADD + `/${familyId}`, data)
}


/**
 * 删除标签
 * @param tagId
 */
export function deleteTagById(tagId: number) {
  return request.delete<string, SysResponse<null>>(API.DELETE + `/${tagId}`)
}

/**
 * 修改标签
 * @param data
 * @param id
 */
export function updateTag(data: TagForm,familyId:number, id: number) {
  return request.put<string, SysResponse<null>>(API.UPDATE + `/${familyId}/${id}`, data)
}
